<?php

/*
 * 高效率计算文件行数
 * @author axiang
*/
  $file='data_log.txt';
  $fp=fopen($file, "r");
  $dateTime=date("Y-m-d");
  $i=0;
  $todaynum=0;
  while(!feof($fp)) {
    //每次读取2M
    if($data=fread($fp,1024*1024*2)){
      //计算读取到的行数
      $num=substr_count($data,"\n");
	  $todaynum=substr_count($data,$dateTime)+$todaynum;
      $i+=$num;
    }
  }
  fclose($fp);

 ?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>访问量统计</title>
</head>
<body>
	<div>
	<h1>
	<?php echo '访问总量统计：'.$i.'次'; ?>	
	</h1>
	<h1>
		当天访问量：<?php echo $todaynum ?>
	</h1>
	</div>
</body>
</html>